# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Serge Victor <arch@random.re>

_pyname=flask-wtf
pkgname=python-flask-wtf
pkgver=1.1.1
pkgrel=2
pkgdesc='Simple integration of Flask and WTForms'
url='https://flask-wtf.readthedocs.io/'
arch=('any')
license=('BSD')
depends=('python-flask' 'python-wtforms' 'python-werkzeug' 'python-flask-babel')
makedepends=('python-setuptools' 'python-sphinx' 'python-pallets-sphinx-themes'
             'python-sphinxcontrib-log-cabinet' 'python-sphinx-issues')
checkdepends=('python-tox')
options=('!makeflags')
source=(${pkgname}-${pkgver}.tar.gz::https://github.com/wtforms/flask-wtf/archive/v${pkgver}.tar.gz)
sha512sums=('4e893ac29051d7c0793f47b8d046b2402902d832a4164408221369d65c170c5c6a16b0d2c7d78e166e82e7fc665118df8c3f1ee51503afaabc053ba236c1f178')

prepare() {
  cd ${_pyname}-${pkgver}
  sed -i "s/^release, version =/& '${pkgver}', '${pkgver%.*}.x' #/" docs/conf.py
}

build() {
  cd ${_pyname}-${pkgver}
  make -C docs man text SPHINXBUILD=sphinx-build
}

check() {
  cd ${_pyname}-${pkgver}
  local python_version=$(python -c 'import sys; print("".join(map(str, sys.version_info[:2])))')
  tox -e py${python_version}
}

package() {
  cd ${_pyname}-${pkgver}
  python setup.py install --root="${pkgdir}" -O1
  install -Dm 644 LICENSE.rst -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -Dm 644 README.rst  -t "${pkgdir}/usr/share/doc/${pkgname}"
  cp -r docs/_build/text "${pkgdir}/usr/share/doc/${pkgname}/text"
  install -Dm 644 docs/_build/man/flask-wtf.1 "${pkgdir}/usr/share/man/man1/${pkgname}.1"
}

# vim: ts=2 sw=2 et:
